<!DOCTYPE html>
<html>
    <style>
        div{
            background-color: coral;
            border: 1px solid;
            padding: 50px;
        }
    </style>
    <body>
        <p>鼠标移动触发监听事件，点击按钮移除监听事件</p>
        <div id="div">
            <button onclick="fun2()">点我</button>
        </div>
        <p id="p2"></p>
        <script>
            document.getElementById("div").addEventListener("mousemove",fun1);
            function fun1(){
                document.getElementById("p2").innerHTML=Math.random();
            }
            function fun2(){
                document.getElementById("div").removeEventListener("mousemove",fun1);
            }
        </script>
    </body>
</html>